<?php
define('INDEX',1);
include ('../../comm/dd.config.php');
include (DDROOT . '/comm/checkpostandget.php');
include (DDROOT . '/mod/inc/header.act.php');

$do = empty ($_GET['do']) ? 'no' : $_GET['do'];

if($do=='no'){
	jump(-1,'非法参数');
}
//头部登录
if($do=='top_user'){
	if($dduser['id']>0){
		if($msgnum==0){ 
			$msgsrc="<a href=\"".u('user','msg')."\"><div class=\"menu_msg\" title=\"站内消息\"></div></a>";
		}else{
			$msgsrc="<a href=\"".u('user','msg')."\"><div class=\"menu_msg_h\" title=\"您有".$msgnum."条未读短消息\"><div class=\"msg\"><i class=\"li_left\"></i><span>".$msgnum."</span><i class=\"li_right\"></i></div></div></a>";
		}
		$userinfo=array('name'=>$dduser['name'],'id'=>$dduser['id'],'money'=>$dduser['money'],'jifenbao'=>$dduser['jifenbao'],'jifen'=>$dduser['jifen'],'level'=>$dduser['level'],'msgsrc'=>$msgsrc,'avatar'=>a($dduser['id']));
		$re=array('s'=>1,'user'=>$userinfo);
		echo dd_json_encode($re);
	}
	else{
		$re=array('s'=>0);
		echo dd_json_encode($re);
	}
}
if($do=='goods_type'){  //首页板块分类
	$bankuai=$duoduo->select('bankuai','id,web_cid,code,fenlei,yugao,yugao_time,huodong_time',"code='".$_GET['code']."' and status=1");
	$yugao_time=date('Y-m-d '.$bankuai['yugao_time'].":00");
	if(strtotime($yugao_time)>TIME){
		$yugao_close=true;
	}
	if($bankuai['fenlei']==1){
		$web_cid=unserialize($bankuai['web_cid']);
		if($web_cid){
			$where="id in(".implode(',',$web_cid).")";
		}
		$goods_type=$duoduo->select_all("type","id,title",$where."  order by sort=0 asc,sort asc,id desc");
		$html='<div class="jy_nav" id="'.$bankuai['code'].'_nav">';
		if($goods_type){
			$html.='<div class="up_fenlei"><a class="cur c_border" href="'.u('goods','index',array('code'=>$bankuai['code'])).'">全部</a>';
			foreach($goods_type as $vo){
				$html.='<a target="_blank" href="'.u('goods','index',array('code'=>$bankuai['code'],'cid'=>$vo['id'])).'">'.$vo['title'].'</a>';
			}
			$html.="</div>";
		
		$html.='<div style="float:right; margin-right:20px">';
		$html.='<a>排序：</a>';
        $html.='<a class="cur c_border" target="_blank" href="'.l('goods','index',array('code'=>$bankuai['code'],'cid'=>$vo['cid'],'do'=>'addtime_desc')).'">最新↓</a>';
        $html.='<a target="_blank" href="'.l('goods','index',array('code'=>$bankuai['code'],'cid'=>$vo['cid'],'do'=>'sell_desc')).'">最热↓</a>';
        $html.='<a target="_blank" href="'.l('goods','index',array('code'=>$bankuai['code'],'cid'=>$vo['cid'],'do'=>'fanli_desc')).'">返利最多↓</a>';
		$html.="</div>";
		}
		 
		 
		if($bankuai['yugao']==1){
			$html.='<div style="float:right; width:85px; margin-right:10px;"><a class="cur c_border" ';
			if($yugao_close){
          	  	$html.='onClick="alert(\'对不起，亲！'.$bankuai['yugao_time'].'后公布预告商品。\')"';
			}else{
				$html.='href="'.u('goods','index',array('code'=>$bankuai['code'],'do'=>'yugao')).'"';
			}
			$html.='>明日精选</a></div>';
		}
		echo $html."</div>";
	}else{
		echo $html.'<div id="'.$bankuai['code'].'_nav"><div>';
	}
	dd_json_encode($html);
	exit;
}
?>